<%
query = @suggest_query || nil
%>

<div class="bubble">
  <div class="content">
    <% form_remote_tag(:update => 'suggestionContainer', :url => {:controller => 'search', :action => 'suggestion_box'}, :html => {:id => 'suggestionForm', :action => '', :style => 'display: none;'}) do %>
      <%= text_field_tag 'suggestionQuery', query %>
    <% end %>
    <%= link_to(image_tag('transparent.gif'), 'javascript: void(0);', :onclick => 'closeSuggest();', :class => 'closeBubble') %>
    <% unless @suggest_query.nil? %>
      <% if @suggestions.length > 0 %>
        <script type="text/javascript">openSuggest();</script>
      <% else %>
        <script type="text/javascript">closeSuggest();</script>
      <% end %>
      <ul class="suggestions">
        <li class="header"><%= @suggest_query[:basic].join(' ') %></li>
        <% @suggestions.each do |suggestion| %>
          <li onclick="$('q').value = '<%= suggestion.content %>';"><%= mark_suggestion(suggestion.content, @suggest_query[:basic].join(' ')) %></li>
          <% suggestion.queries do |token_query| %>
            <li onclick="$('q').value = '<%= token_query.query_to_s %>';"><%= mark_suggestion(token_query.query_to_s, @suggest_query[:basic].join(' ')) %></li>
          <% end %>
        <% end %>
      </ul>
      <ul class="synonims">
        <li class="header">synonims:</li>
        <% @synonims.each do |synonim| %>
          <li onclick="$('q').value = '<%= synonim.content %>';"><%= synonim.content %></li>
        <% end %>
      </ul>
    <% end %>
  </div>
</div>